package com.foreknow.elmboot.controller;

import com.foreknow.elmboot.po.Order;
import com.foreknow.elmboot.po.User;
import com.foreknow.elmboot.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/OrderController")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @RequestMapping("/getOrdersById")
    public Order getOrdersById(Order order) throws Exception{
        return orderService.getOrdersById(order.getOrderId());
    }

    @RequestMapping("/CreateOrder")
    public int CreateOrder(Order order) throws Exception{
        return orderService.CreateOrder(order);
    }
    @RequestMapping("/listOrderByUserId")
    public List<Order> listOrderByUserId(String userId) throws Exception{
        return orderService.listOrderByUserId(userId);
    }
    @RequestMapping("/updateOrderByOrderId")
    public int updateOrderByOrderId(Integer orderId) throws Exception{
        return orderService.updateOrderByOrderId(orderId);
    }
}